package com.loiot.baqi.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.loiot.baqi.controller.response.Pager;
import com.loiot.baqi.dao.ZpPositionTypeKeysDao;
import com.loiot.baqi.service.ZpPositionTypeKeysService;
import com.loiot.baqi.pojo.ZpPositionTypeKeys;
import com.loiot.baqi.pojo.ZpJlJobLevels;


/**
 * 职位类型标签 逻辑类。
 * 
 * @author  wangzx 
 * @creation 2016-03-26
 */
@Service("zpPositionTypeKeysService")
@Transactional
public class ZpPositionTypeKeysService{
    
    private Logger log = LoggerFactory.getLogger(this.getClass());
    
    @Resource
	private ZpPositionTypeKeysDao zpPositionTypeKeysDao;
	
	
	 /**
     * 查询 职位类型标签列表分页
     * 
     * @param name 职位类型标签名称
     * @param pageIndex 页索引
     * @return
     */
    public Pager<ZpPositionTypeKeys> queryZpPositionTypeKeysListPage(HashMap<String,Object> pMap, int pageIndex)throws Exception {

        // 查询职位类型标签列表总条数
        int totalResults = zpPositionTypeKeysDao.getZpPositionTypeKeysListCount(pMap);

        // 构造一个分页器
        Pager<ZpPositionTypeKeys> pager = new Pager<ZpPositionTypeKeys>(totalResults, pageIndex);

        // 查询职位类型标签列表
        List<ZpPositionTypeKeys> zpPositionTypeKeysList = zpPositionTypeKeysDao.queryZpPositionTypeKeysList(pMap, pager.getSkipResults(),
                pager.getMaxResults());
        pager.setData(zpPositionTypeKeysList);
        return pager;
    }
    
    
    
    
    /**
     * 查询 职位类型标签（假）分页
     * 
     * @param name 职位类型标签名称
     * @param pageIndex 页索引
     * @return
     */
    public Pager<ZpPositionTypeKeys> queryFlasePageList(HashMap<String,Object> pMap, int pageIndex)throws Exception {
    	//假分页
    	Pager<ZpPositionTypeKeys> pager = this.setPkList(pMap,pageIndex);
    	List<ZpPositionTypeKeys> zpPositionTypeKeysList = zpPositionTypeKeysDao.queryZpPositionTypeKeysList(pMap);
        pager.setData(zpPositionTypeKeysList);
        return pager;
    }
    
    /**
     * 设置 假分页id集合到Map中
     * @param pMap
     * @param pageIndex
     * @return
     * @throws Exception
     */
    public Pager<ZpPositionTypeKeys> setPkList(HashMap<String,Object> pMap,int pageIndex) throws Exception{
    	  // 查询职位匹配信息列表总条数
        List<ZpPositionTypeKeys> list = zpPositionTypeKeysDao.queryZpPositionTypeKeysList(pMap);
        // 构造一个分页器
        Pager<ZpPositionTypeKeys> pager = new Pager<ZpPositionTypeKeys>(list.size(), pageIndex, 5,list);
        List<ZpPositionTypeKeys> idsList = pager.getCurrentPageData();
        List<Long> ids =this.getIds(idsList);
        pMap.put("ids", ids);
        return pager;
    }
	
	 /**
     * 添加 职位类型标签
     * 
     * @param p 参数对象
     */
    public ZpPositionTypeKeys addZpPositionTypeKeys(ZpPositionTypeKeys p)throws Exception {
       return  zpPositionTypeKeysDao.addZpPositionTypeKeys(p);
    }
    
    /**
     * 修改 职位类型标签
     * 
     * @param p 参数对象
     */
    public void updateZpPositionTypeKeys(ZpPositionTypeKeys p)throws Exception {
        zpPositionTypeKeysDao.updateZpPositionTypeKeys(p);
    }
    
    /**
     * 修改 职位类型标签
     * 
     * @param p 参数对象
     */
    public void updateZpPositionTypeKeys(HashMap<String,Object> pMap)throws Exception {
        zpPositionTypeKeysDao.updateZpPositionTypeKeys(pMap);
    }
    
    /**
     * 删除  职位类型标签
     * 
     * @param id 主键
     */
    public void deleteZpPositionTypeKeys(java.lang.Long id)throws Exception {
        zpPositionTypeKeysDao.deleteZpPositionTypeKeys(id);
    }
    
    /**
     * 删除  职位类型标签
     * 
     * @param id 主键
     */
    public void deleteZpPositionTypeKeys(ZpPositionTypeKeys p)throws Exception {
        zpPositionTypeKeysDao.deleteZpPositionTypeKeys(p);
    }
    
    /**
     * 获得  职位类型标签
     * 
     * @param id 职位类型标签Id
     * 
     * @return 返回与ID匹配的职位类型标签
     */
    public ZpPositionTypeKeys getZpPositionTypeKeysById(java.lang.Long id)throws Exception {
        return  zpPositionTypeKeysDao.getZpPositionTypeKeysById(id);
    }
    
    /**
     * 获得  职位类型标签
     * 
     * @param id 职位类型标签Id
     * 
     * @return 返回与ID匹配的职位类型标签
     */
    public ZpPositionTypeKeys getZpPositionTypeKeysById(java.lang.Long id,Long accountId)throws Exception {
        return  zpPositionTypeKeysDao.getZpPositionTypeKeysById(id,accountId);
    }
    
    
    /**
     * 获得  职位类型标签
     * 
     * @param id 职位类型标签Id
     * 
     */
    public ZpPositionTypeKeys getZpPositionTypeKeys(HashMap<String,Object> pMap)throws Exception {
    	return (ZpPositionTypeKeys) zpPositionTypeKeysDao.getZpPositionTypeKeys(pMap);
    }
    /**
     * 获得  职位类型标签
     * 
     * @param name 职位类型标签名称
     * 
     * @return 返回与NAME匹配的职位类型标签
     */
    public ZpPositionTypeKeys getZpPositionTypeKeysByName(String name)throws Exception {
        return  zpPositionTypeKeysDao.getZpPositionTypeKeysByName(name);
    }
    
    /**
     * 查询 职位类型标签列表
     * @return 职位类型标签列表
     */
    public List<ZpPositionTypeKeys> queryZpPositionTypeKeysList(HashMap<String,Object> pMap)throws Exception {
        return  zpPositionTypeKeysDao.queryZpPositionTypeKeysList(pMap);
    }
    
    /**
     * 查询 职位类型标签列表
     * @return 职位类型标签列表
     */
    public List<ZpPositionTypeKeys> queryZpPositionTypeKeysList(ZpPositionTypeKeys p)throws Exception {
        return  zpPositionTypeKeysDao.queryZpPositionTypeKeysList(p);
    }
    
    /**
     * 查询  职位类型标签列表条数
     * 
     * @param name 职位类型标签名称
     * @return 职位类型标签列表条数
     */
    
    public int getZpPositionTypeKeysListCount(HashMap<String,Object> pMap)throws Exception {
        return  zpPositionTypeKeysDao.getZpPositionTypeKeysListCount(pMap);
    }
    
    /**
     * 查询id集合
     * @return
     */
    public List<Long> getIds(List<ZpPositionTypeKeys> list) {
    	List<Long> idsList = null;
        if(list!=null && list.size()>0) {
        	idsList = new ArrayList<Long>();
        	for (ZpPositionTypeKeys b : list) {
            	idsList.add(null);
            }
        }
        return idsList;
    }
    
    /**
     * 统计 职位类型标签列表
     * 
     * @return 职位类型标签列表
     */
    public List<HashMap<String,Object>> statisticsZpPositionTypeKeysInfo(HashMap<String, Object> pMap )throws Exception {
    	return  zpPositionTypeKeysDao.statisticsZpPositionTypeKeysInfo(pMap);
    }
}
